﻿using System;
using Event.EventBus;

namespace Event.Authentication.EventBusPattern
{
    public class EmailService:IObservedService
    {
        private readonly UserService _userService;
        private readonly IMessenger _messenger;

        public EmailService(UserService userService,IMessenger messenger)
        {
            _userService = userService;
            _messenger = messenger;
        }

        public void RegisterSubject()
        {
            _messenger.Register<UserRegisteredMessage>(_userService, SendEmail);

        }

        public void SendEmail(UserRegisteredMessage user)
        {
            Console.WriteLine("send email successfully");
        }

     
    }
}